package com.glsc.ngateway.common.base.domain.mysql.opmanagemain.ledger;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author liwei
 * 台账操作记录表
 */
@Data
@Entity
@Table(name = "t_business_ledger_opt_log")
@org.hibernate.annotations.Table(appliesTo = "t_business_ledger_opt_log", comment = "台账操作记录表")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class BusinessLedgerOptLog implements Serializable {
    private static final long serialVersionUID = 2051916036596605360L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition = "int(20) comment '台账id'")
    private Integer id;

    @Column(name = "ledger_id", columnDefinition = "int(20) comment '台账id'")
    private Integer ledgerId;

    @Column(name = "ledger_task_id", columnDefinition = "int(20) comment '台账任务id'")
    private Integer ledgerTaskId;

    @ApiModelProperty(value = "原数据")
    @Column(name = "old_ledger_data", columnDefinition = "varchar(255) COMMENT '原数据'")
    private String oldLedgerData;

    @ApiModelProperty(value = "新数据")
    @Column(name = "new_ledger_data", columnDefinition = "varchar(255) COMMENT '新数据'")
    private String newLedgerData;

    @ApiModelProperty(value = "操作类型")
    @Column(name = "opt_type", columnDefinition = "varchar(200) COMMENT '操作类型 1修改台账任务的工作值'")
    private String optType;

    @Column(name = "create_id", columnDefinition = "int DEFAULT NULL COMMENT '创建人id'")
    @ApiModelProperty(value = "创建人id")
    private Long createId;

    @ApiModelProperty(value = "创建人名称")
    @Column(name = "create_name", columnDefinition = "varchar(100) COMMENT '创建人名称'")
    private String createName;

    @ApiModelProperty(value = "创建时间 yyyy-MM-dd HH:mm:ss")
    @Column(name = "create_time", columnDefinition = "datetime comment '创建时间'", updatable = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;


}
